package cn.fu.aop.annotation;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * 切面类
 * @author 99fu
 *
 */
@Aspect//这个类为切面类
@Component//因为作为切面类需要Spring管理起来，所以在初始化时就需要将这个类初始化加入Spring的管理；
public class LogInterceptor {
	//@Before 切入点的逻辑(Advice)    execution…:切入点语法
//	  @Before("execution(* cn.fu.aop.Common.execute(..))")

	    @Pointcut("execution(public * cn.fu.core.service..*.selectTestTbList(..))") 
	    public void myMethod(){}; 
	     
	    /*@Before("execution(public void cn.fu.core.service.TestTbServiceImpl.selectTestTbList())")*/ 
	    @Before("myMethod()") //1.执行之前
	    public void before() { 
	        System.out.println("method staet"); 
	    }  
	    @After("myMethod()") //3.执行后
	    public void after() { 
	        System.out.println("method after"); 
	    }  
	    @AfterReturning("execution(public * cn.fu.core.dao..*.*(..))") //2.执行时
	    public void AfterReturning() { 
	        System.out.println("method AfterReturning"); 
	    }  
	    @AfterThrowing("execution(public * cn.fu.core.dao..*.*(..))") //抛出异常时
	    public void AfterThrowing() { 
	        System.out.println("method AfterThrowing"); 
	    }  
	    
	    /*{dataSource-1} inited
		method staet
		测试AOP:执行此方法
		method AfterReturning
		method after*/
}
